<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>酒店管理系统主页</title>

    <link rel="stylesheet" href="../../css/select.css" type="text/css"></link>
    <link rel="stylesheet" href="../../css/style.css" type="text/css"></link>

    <script type="text/javascript" src="../../js/jquery-1.8.3.min.js"></script>
    <script>
        $(function () {
            alert(11111);
            $.ajax({
                url: '../../roomtype/getRoomType',
                type: "post",
                data : {},
                async : false,
                success : function(data) {
                    var roomty="";
                    for(var i=0;i<data.data.length;i++){    //遍历data数组
                        var ls = data[i].data;
                        roomty +="<option value='"+ls.rid+"' selected>"+ls.type+"</option>";
                    }
                      option = '<select  name="roomtype" size="1" id="select" style="width:100px;">'+
                          roomty + '</select>' ;
                          $("#ul").html(roomty);
                       },
            })
        })
    </script>
</head>
<body>
<div class="place"> <span>位置：</span>
    <ul class="placeul">
        <li><a href="main.html">首页</a></li>
        <li><a href="#">客房管理</a></li>
        <li><a href="#">添加客房</a></li>
    </ul>
</div>
<div class="formbody">
    <div class="formtitle"><span>修改房间类型</span></div>
    <div id="usual1" class="usual">
        <div id="tab1" class="tabson">
                <ul class="forminfo">

                    <li>
                        <label>类型编号<b>*</b></label>
                        <div class="vocation">
                            <input  readonly="readonly" type="text" name="rid" id="rid"  class="dfinput" placeholder="请输入要修改的房间类型编号"  style="width:344px;"/>
                            <span id="priceSpan">&nbsp;</span>
                        </div>
                    </li>

                    <li>
                        <label>客房类型<b>*</b></label>
                        <div class="vocation">
                            <input  type="text" name="type" id="type"  class="dfinput" placeholder="请输入要修改的客房类型"  style="width:344px;"/>
                            <span id="priceSpan">&nbsp;</span>
                        </div>
                    </li>
                    <li id="ulul"> </li>

                    <br/>
                    <li>
                        <label>&nbsp;</label>
                        <input name="button" type="button" onclick="uproom()" class="btn" value="修改"/>
                    </li>

                </ul>
        </div>
    </div>
</div>
<script>
    window.onload = function () {
        document.getElementById('rid').value = localStorage.getItem('rid');
    }
    function uproom() {
        var rid = $("#rid").val();
        var type=$("#type").val();
        alert(rid+type);
        $.ajax({
            url: "../../roomtype/updateRT",
            type: "POST",
            data: {
                rid: rid,
                type: type
            },
            success: function (data, status) {
                if (status == "success") {
                    console.log('请求成功');
                    console.log(data);
                    if (data.state == 0) {
                        window.location = "SelectRoomtype.html";
                    } else {
                        alert("修改失败")
                    }

                }
            }
        });
    }
</script>
</body>
</html>